<%
	Session("bChucnang")=3
	Session("FormName")="F20"
%>
<!--#include file="..\CheckSession.inc"-->
<%
	bTungay=Request("TxtTungay")
	bDenngay=Request("TxtDenngay")
	bNgayIn=Request("NgayIn")
	bInForDate=false
	ChonSql=false
	Set Cls=server.CreateObject("Vinalines.ClsFunction")
	sNgaythang=""
%>
<HTML>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<TITLE>Quản Trị Văn Thư</TITLE>
<style type="text/css">
<!--
	br.page { page-break-before: always; }
-->
</style>
<script language=vbscript runat=server>
Function FormatDate(vDate)
	   If Not IsNull(vDate) Then
	        vM = Right("0" & Month(vDate), 2)
	        vD = Right("0" & Day(vDate), 2)
	        vY = Right("19" & Year(vDate), 4)
	        FormatDate = vD & "/" & vM & "/" & vY
	   End If
End Function
Function SaveDate(vDate)
		dim bvitri1
		dim bvitri2
	   vDate=trim(cstr(vDate))
	   bvitri1=instr(1,vDate,"/")
	   bMonth=left(vDate,bvitri1-1)
	   bvitri2=instr(bvitri1+1,vDate,"/")
	   Dim Temp
	   Temp=right(vDate,len(vDate)-bvitri1)
	   bDay=left(Temp,bvitri2-bvitri1-1)
	   bYear=right(vDate,len(vDate)-bvitri2)
       SaveDate=bDay+"/"+bMonth+"/"+bYear
End Function
</script>
<Body style="font-family:Times new roman" topmargin=0 leftmargin=0>
<Center>
<form name=frm method=post>
		<%		
		if bNgayIn <> "" then
			if session("bIn")<>"OFF" then
				Set RecCheck=server.CreateObject("ADODB.Recordset")
				RecCheck.CursorType=3
				RecCheck.CacheSize=5
				ssql="select * from incongvan where ngaycongvan < '" & savedate(bNgayIn) & "' and loaicongvan=3 order by ngaycongvan desc"
				RecCheck.Open sSQL,Conn
				if RecCheck.recordcount > 0 then
					ChonSql=true
				end if
				RecCheck.movefirst
				if not RecCheck.eof then
					strNgayTruoc=Formatdate(RecCheck("ngaycongvan"))
				end if
				intsothang=cint(mid(trim(cstr(bNgayIn)),4,2))-cint(mid(trim(cstr(strNgayTruoc)),4,2))
					intSoCongVan=RecCheck("socongvancuoi")
					intSoTrang=RecCheck("sotrangcuoi")
					if ChonSql=true then
						sSQL="select vtquyetdinh.*,diachiluutru.ten from vtquyetdinh,diachiluutru where (vtquyetdinh.diachiluutru=diachiluutru.idluutru) and ((ngaydi = '" & savedate(strNgayTruoc) & "' and so >= " & cint(intSoCongVan) & ") or (ngaydi > '" & savedate(strNgayTruoc) & "' and ngaydi <='" & savedate(bNgayIn) & "'))  order by ngaydi,so"
					else
						sSQL="select vtquyetdinh.*,diachiluutru.ten from vtquyetdinh,diachiluutru where vtquyetdinh.diachiluutru=diachiluutru.idluutru and ngaydi ='" & savedate(bNgayIn) & "' order by ngaydi,so"
					end if

					if intsothang=0 then
						oldnumberpage=cint(intSoTrang)
					else
						oldnumberpage=1
					end if
				RecCheck.close
				set RecCheck = nothing
				bInForDate=true
			else
				sSQL=Request("PrintValue") 
				sSQL=sSQL+" order by ngaydi,so"
				oldnumberpage=1
			end if
		else
				sSQL=Request("PrintValue") 
				sSQL=sSQL+" order by ngaydi,so"
				oldnumberpage=1
		end if
			sheightbang="670px"
			sheightdong="45px"
			sSQL="Select * from VTQuyetdinh order by ngaydi,so"
			Set RecCB=server.CreateObject("ADODB.Recordset")
			RecCB.CursorType=3
			RecCB.CacheSize=5
			RecCB.Open sSQL,Conn
			chktstrang=round(RecCB.recordcount/12-0.5)
			cnt=1
			count=1
			numberpage=oldnumberpage
			if numberpage=0 then
				numberpage=1
			end if
			tstrang=1
			if chktstrang < 1 then
			%>
			<Table border="2" width="100%" cellspacing="0" cellpadding="0" style="border-collapse: collapse" bordercolor="#111111" >
			<TR height="50px">	
			<TD width=5% align=center><font size="2"><strong>Ngày CV</strong></font></TD>
			<TD width=10% align=center><font size="2"><strong>Số & ký hiệu</strong></font></TD>	
			<TD width=25%  align=center ><font size="2"><strong>Trích yếu nội dung</strong></font></TD>
			<TD width=15% align=center ><font size="2"><strong>Người ký</strong></font></TD>
			<TD width=15% align=center ><font size="2"><strong>Nơi nhận</strong></font></TD>
			<TD width=10% align=center ><font size="2"><strong>Ðơn vị lưu CV</br></strong></font></TD>
			<TD width=5% align=center ><font size="2"><strong>Số bản</strong></font></TD>
			<TD width=5% align=center ><font size="2"><strong>Số <br>tờ</strong></font></TD>
			<TD width=10% align=center ><font size="2"><strong>Ghi chú</strong></font></TD>
			</TR>
			<%
			else
			%>
			<Table border="2" width="100%" height="<%=sheightbang%>" cellspacing="0" cellpadding="0" style="border-collapse: collapse" bordercolor="#111111" >
			<TR height="50px">	
			<TD width=5% align=center><font size="2"><strong>Ngày CV</strong></font></TD>
			<TD width=10% align=center><font size="2"><strong>Số & ký hiệu</strong></font></TD>	
			<TD width=25%  align=center ><font size="2"><strong>Trích yếu nội dung</strong></font></TD>
			<TD width=15% align=center ><font size="2"><strong>Người ký</strong></font></TD>
			<TD width=15% align=center ><font size="2"><strong>Nơi nhận</strong></font></TD>
			<TD width=10% align=center ><font size="2"><strong>Ðơn vị lưu CV</br></strong></font></TD>
			<TD width=5% align=center ><font size="2"><strong>Số bản</strong></font></TD>
			<TD width=5% align=center ><font size="2"><strong>Số <br>tờ</strong></font></TD>
			<TD width=10% align=center ><font size="2"><strong>Ghi chú</strong></font></TD>
			</TR>
			<%
			end if
			Do while not RecCB.EOF	
				if (cnt/2=int(cnt/2)) then
					color="#eeeecc"
				else
					color="#F8F9D9"
				end if
				color="white"
			if count > 12 then
				cnsoghinhan=RecCB("so")
				Response.Write "</table>"
				response.write "<br class=""page"" />"
				count=1
				numberpage=numberpage+1
				tstrang=tstrang+1
			if  tstrang > chktstrang then
			%>
			<Table border="2" width="100%" cellspacing="0" cellpadding="0" style="border-collapse: collapse" bordercolor="#111111" >
			<TR height="50px">
			<TD width=5% align=center><font size="2"><strong>Ngày CV</strong></font></TD>
			<TD width=10% align=center><font size="2"><strong>Số & ký hiệu</strong></font></TD>	
			<TD width=25%  align=center ><font size="2"><strong>Trích yếu nội dung</strong></font></TD>
			<TD width=15% align=center ><font size="2"><strong>Người ký</strong></font></TD>
			<TD width=15% align=center ><font size="2"><strong>Nơi nhận</strong></font></TD>
			<TD width=10% align=center ><font size="2"><strong>Ðơn vị lưu CV</br></strong></font></TD>
			<TD width=5% align=center ><font size="2"><strong>Số bản</strong></font></TD>
			<TD width=5% align=center ><font size="2"><strong>Số <br>tờ</strong></font></TD>
			<TD width=10% align=center ><font size="2"><strong>Ghi chú</strong></font></TD>
			</TR>
			<TR bgcolor="<%=color%>" height="<%=sheightdong%>">	
				<TD width=5% align=center><font size="2">&nbsp;<%=cls.FormatDate(RecCB("Ngaydi"))%>&nbsp;</font></TD>			
				<TD width=10%><font size="2">&nbsp;<%=RecCB("soghinhan")%></font></TD>			
				<TD width=25% ><font size="2">&nbsp;<%=RecCB("Trichyeu")%>&nbsp;</font></TD>
				<TD width=15% align=center><font size="2">&nbsp;<%=RecCB("nguoiky")%>&nbsp;</font></TD>
				<TD width=15% ><font size="2">&nbsp;<%=RecCB("noinhan")%>&nbsp;</font></TD>
				<TD width=10% ><font size="2">&nbsp;<%=RecCB("Ten")%>&nbsp;</font></TD>
				<TD width=5% align=center><font size="2">&nbsp;<%=RecCB("soban")%>&nbsp;</font></TD>
				<TD width=5% align=center><font size="2">&nbsp;<%=RecCB("soto")%>&nbsp;</font></TD>
				<TD width=10% >&nbsp;</TD>
			</TR>
			<%
			else
			%>
			<Table border="2" width="100%" height="<%=sheightbang%>" cellspacing="0" cellpadding="0" style="border-collapse: collapse" bordercolor="#111111" >
			<TR height="50px">
			<TD width=5% align=center><font size="2"><strong>Ngày CV</strong></font></TD>
			<TD width=10% align=center><font size="2"><strong>Số & ký hiệu</strong></font></TD>	
			<TD width=25%  align=center ><font size="2"><strong>Trích yếu nội dung</strong></font></TD>
			<TD width=15% align=center ><font size="2"><strong>Người ký</strong></font></TD>
			<TD width=15% align=center ><font size="2"><strong>Nơi nhận</strong></font></TD>
			<TD width=10% align=center ><font size="2"><strong>Ðơn vị lưu CV</br></strong></font></TD>
			<TD width=5% align=center ><font size="2"><strong>Số bản</strong></font></TD>
			<TD width=5% align=center ><font size="2"><strong>Số <br>tờ</strong></font></TD>
			<TD width=10% align=center ><font size="2"><strong>Ghi chú</strong></font></TD>
			</TR>
			<TR bgcolor="<%=color%>" height="<%=sheightdong%>">	
				<TD width=5% align=center><font size="2">&nbsp;<%=cls.FormatDate(RecCB("Ngaydi"))%>&nbsp;</font></TD>			
				<TD width=10%><font size="2">&nbsp;<%=RecCB("soghinhan")%></font></TD>			
				<TD width=25% ><font size="2">&nbsp;<%=RecCB("Trichyeu")%>&nbsp;</font></TD>
				<TD width=15% align=center><font size="2">&nbsp;<%=RecCB("nguoiky")%>&nbsp;</font></TD>
				<TD width=15% ><font size="2">&nbsp;<%=RecCB("noinhan")%>&nbsp;</font></TD>
				<TD width=10% ><font size="2">&nbsp;<%=RecCB("Ten")%>&nbsp;</font></TD>
				<TD width=5% align=center><font size="2">&nbsp;<%=RecCB("soban")%>&nbsp;</font></TD>
				<TD width=5% align=center><font size="2">&nbsp;<%=RecCB("soto")%>&nbsp;</font></TD>
				<TD width=10% >&nbsp;</TD>
			</TR>
			<%
			end if
			else
			%>
			<TR bgcolor="<%=color%>" height="<%=sheightdong%>">	
				<%if sNgaythang<>RecCB("ngaydi") then
					sNgaythang=RecCB("ngaydi")%>	
					<TD width=5% align=center><font size="2">&nbsp;<%=cls.FormatDate(RecCB("Ngaydi"))%>&nbsp;</font></TD>
				<%else%>
					<%if sNgaythang<>"" then%>
						<td width="5%" align=center height="19">"</td>
					<%else%>
						<td width="5%" align=center height="19"></td>
					<%end if%>
				<%end if %>			
				<TD width=10%><font size="2">&nbsp;<%=RecCB("soghinhan")%></font></TD>			
				<TD width=25% ><font size="2">&nbsp;<%=RecCB("Trichyeu")%>&nbsp;</font></TD>
				<TD width=15% align=center><font size="2">&nbsp;<%=RecCB("nguoiky")%>&nbsp;</font></TD>
				<TD width=15% ><font size="2">&nbsp;<%=RecCB("noinhan")%>&nbsp;</font></TD>
				<TD width=10% ><font size="2">&nbsp;<%=RecCB("Ten")%>&nbsp;</font></TD>
				<TD width=5% align=center><font size="2">&nbsp;<%=RecCB("soban")%>&nbsp;</font></TD>
				<TD width=5% align=center><font size="2">&nbsp;<%=RecCB("soto")%>&nbsp;</font></TD>
				<TD width=10% >&nbsp;</TD>
			</TR>
			<%
			end if
				RecCB.MoveNext
				count=count+1
				cnt=cnt+1
				bSTT=bSTT+1
			Loop
			if bInForDate=true and chktstrang >= 1 then
				chkSql="delete from incongvan where ( ngaycongvan='" & savedate(bNgayIn) & "' and loaicongvan =3 ) or ( ngaycongvan < '" & dateadd("m",-1,date) & "' and loaicongvan =3 )"
				conn.Execute chkSql
				chkSql="insert into incongvan(ngaycongvan,socongvancuoi,sotrangcuoi,loaicongvan) values ( '" & savedate(bNgayIn) & "'," & cint(cnsoghinhan) & "," & numberpage & ",3)"
				conn.Execute chkSql
			end if
		%>
	</Table>
</Form>
</Center>
<Body>
<%
	Cls=nothing
	Conn.Close
	Set Conn=nothing
%>
</HTML>